home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Metrowerks Versions / C07 QuickTime Movies / P03 Select Movie / SelectMovie.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  2.6 KB  |  111 lines  |  [TEXT/MMCC]

  1. //____________________________________________________________
  2. //    SelectMovie.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Movies.h>
  13. #include <Gestalt.h>
  14.  
  15.  
  16. //____________________________________________________________
  17.  
  18. void  InitializeAllToolboxes( void );
  19.  
  20.  
  21. //____________________________________________________________
  22.  
  23. #define      rMovieWindow        128
  24.  
  25.  
  26. //____________________________________________________________
  27.  
  28. void  main( void )
  29.    OSErr              theError;
  30.    FSSpec             theFSSpec;
  31.    short              theFileRefNum;
  32.    Movie              theMovie;
  33.    short              theMovieResID = 0;   
  34.    Str255             theMovieResName;
  35.    Boolean            wasAltered;
  36.    WindowPtr          theWindow;
  37.    Rect               theMovieBox;
  38.    SFTypeList         typeList = { MovieFileType, 0, 0, 0 };
  39.    StandardFileReply  theReply;
  40.  
  41.    InitializeAllToolboxes();
  42.    
  43.    StandardGetFilePreview( nil, 1, typeList, &theReply );
  44.  
  45.    if ( theReply.sfGood == true )
  46.    {          
  47.       theError = OpenMovieFile( &theReply.sfFile, &theFileRefNum, fsRdPerm );
  48.       theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
  49.                                     theMovieResName, newMovieActive, &wasAltered );
  50.       CloseMovieFile( theFileRefNum );
  51.    }
  52.    else
  53.    {
  54.       ExitToShell();
  55.    }
  56.    
  57.    theWindow = GetNewCWindow( rMovieWindow, nil, (WindowPtr)-1L );   
  58.  
  59.    SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );   
  60.  
  61.    GetMovieBox( theMovie, &theMovieBox );
  62.    OffsetRect( &theMovieBox, -theMovieBox.left, -theMovieBox.top );
  63.    SetMovieBox( theMovie, &theMovieBox );
  64.  
  65.    SizeWindow( theWindow, theMovieBox.right, theMovieBox.bottom, true );  
  66.    ShowWindow( theWindow);
  67.  
  68.    GoToBeginningOfMovie( theMovie );
  69.  
  70.    StartMovie( theMovie );
  71.  
  72.    do
  73.    {
  74.       MoviesTask(theMovie, 0);
  75.    }
  76.    while ( IsMovieDone( theMovie ) == false );
  77.    
  78.    DisposeMovie( theMovie );
  79.    DisposeWindow( theWindow );
  80. }
  81.  
  82.  
  83. //____________________________________________________________
  84.  
  85. void  InitializeAllToolboxes( void )
  86. {
  87.    OSErr  theError;
  88.    long   theResult;
  89.  
  90.    InitGraf( &qd.thePort );
  91.    InitFonts();
  92.    InitWindows();
  93.    InitMenus();
  94.    TEInit();
  95.    InitDialogs( 0L );
  96.    FlushEvents( everyEvent, 0 );
  97.    InitCursor();
  98.  
  99.    theError = Gestalt( gestaltQuickTime, &theResult );
  100.    if ( theError != noErr )
  101.       ExitToShell();
  102.                                                  
  103.    theError = EnterMovies();  
  104.    if ( theError != noErr )
  105.       ExitToShell(); 
  106. }
  107.  
  108.  
  109.  
  110.